{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "54142cbd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "旺财汪汪\n"
     ]
    }
   ],
   "source": [
    "class Animal():\n",
    "    def __init__(self,name):\n",
    "        self.name=name\n",
    "    def speak():\n",
    "        pass\n",
    "class Dog(Animal):\n",
    "    def __init__(self,name):\n",
    "        super().__init__(name)\n",
    "    def speak(self,r):\n",
    "        print(f\"{self.name}{r}\")\n",
    "a=Dog(\"旺财\")\n",
    "a.speak(\"汪汪\")\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "db522188",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "class activation():\n",
    "    def relu(x):\n",
    "        return np.maximum(0,x)\n",
    "    def sigmoid(x):\n",
    "        return 1/(1+np.exp(-1))\n",
    "    def tanh(x):\n",
    "        return np.tanh(x)\n",
    "    def softmax(x):\n",
    "        return np.exp(x)/np.sum(np.exp(x))\n",
    "class Perception():\n",
    "    def __init__(self):\n",
    "        self.w=np.ones(len(data[0])-1)\n",
    "        self.b=0\n",
    "        self.rate=0.5\n",
    "    def fit(self,x_train,y_train):\n",
    "        while True:\n",
    "            flag=True\n",
    "            for i in range(len(x_train)):\n",
    "                xi=x_train[i]\n",
    "                yi=y_train[i]\n",
    "                if yi*(np.inner(self.w,xi)+self.b)<=0:\n",
    "                    flag=False\n",
    "                    self.w+=self.rate*np.dot(xi,yi)\n",
    "                    self.b+=self.rate*yi\n",
    "            if flag:\n",
    "                break\n",
    "        print(f\"w={self.w},b={self.b}\")\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "cv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
